/**
 * @class   wosh::network::NetworkProtocolUdp
 * @brief   wosh::NetworkProtocol implementation based on UDP protocol.
 *
 * @see     wosh::NetworkManager
 ****************************************************************************
 * @version $Id: NetworkProtocolUdp.h 2585 2010-05-27 16:30:53Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Network_NetworkProtocolUdp_H__
 #define __WOSH_Network_NetworkProtocolUdp_H__

 #include <core/NetworkProtocol.h>
 #include <core/NetworkManager.h>
 #include <framework/network/NetworkChannelUdp.h>


namespace wosh {
 namespace network {

 #define _NetworkProtocolUdp_NAME			"NetworkProtocolUDP"
 #define _NetworkProtocolUdp_PREFIX			"UDP://"
 #define _NetworkProtocolUdp_Priority		20


class NetworkProtocolUdp :  public wosh::NetworkProtocol
 {
	WOSH_CLASSNAME(wosh::network::NetworkProtocolUdp)
	WOSH_CLASS_ABSTRACT(false)

	public:
		NetworkProtocolUdp();
		virtual ~NetworkProtocolUdp() { }

	public:
		bool supportProtocol( const std::string& protocol_string ) const;

		inline const char* getProtocolPrefix() const	{ return _NetworkProtocolUdp_PREFIX; }
		inline int getPriority() const					{ return _NetworkProtocolUdp_Priority; }

		inline int getServersCount() const				{ return -1; }
		inline int getClientsCount() const				{ return -1; }

	public:
		WRESULT listenChannel( const std::string& protocol_string, unsigned long timeout = LIMIT_ULONG_MAX );

		WRESULT connectChannel( const std::string& protocol_string, unsigned long timeout = LIMIT_ULONG_MAX );
		WRESULT connectChannel( const std::vector<std::string>& protocolsAvailable, unsigned long timeout = LIMIT_ULONG_MAX );

	private:
		NetworkProtocolUdp(const NetworkProtocolUdp&) { }
		NetworkProtocolUdp& operator=(const NetworkProtocolUdp&) { return *this; }


}; // class def

 }; // namespace network
}; // namespace wosh

#endif //__WOSH_Network_NetworkProtocolUdp_H__
